# define _CRT_SECURE_NO_WARNINGS 1
int bin_search(int arr[], int left, int right, int key)
{
	while (left <= right)
	{
		int mid = (left + right) / 2;
		if (arr[mid] < key)
		{
			left = mid + 1;
		}
		else if (arr[mid] > key)
		{
			right = mid - 1;
		}
		else if(arr[mid] == key)
		{
			return mid;
		}
	}
	return -1;
}
